/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */

typedef struct ListNode ListNode;

void Push_Head(ListNode* head, ListNode* t)
{
    t->next = head->next;
    head->next = t;
}
struct ListNode* reverseList(struct ListNode* head)
{
    if (!head)
        return head;

    ListNode* plist = (ListNode*)malloc(sizeof(ListNode));
    ListNode* p = NULL;
    ListNode* ne = head;

    int cnt = 0;
    while (ne)
    {
        cnt++;
        p = ne;
        ne = p->next;
        Push_Head(plist, p);
        if (cnt == 1)
            head->next = NULL;
    }

    ListNode* res = plist->next;

    free(plist);

    return res;
}}